<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ include file="/WEB-INF/jsp/component/common.jsp" %>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="">
    <meta name="author" content="">
    <title>医院工单信息</title>
    <%@include file="/WEB-INF/jsp/component/commonHead.jsp" %>
    <%@include file="/WEB-INF/jsp/component/commonBottom.jsp" %>
    <!-- bootstrapValidator验证 -->
    <link href="${assets}/bootstrapValidator/css/bootstrapValidator.css" rel="stylesheet"/>
</head>
<body style="width: 98%">
<div class="row">
    <div class="col-lg-12">
        <h1 class="page-header">医院工单信息</h1>
    </div>
    <!-- /.col-lg-12 -->
</div>
<!-- /.row -->
<div class="row">
<form id="myForm" class="form-horizontal" method="post" >
    <div class="form-group">
        <label class="col-sm-2 control-label">工单名称</label><label class="col-sm-10 navbar-btn">${order.orderName}</label>
    </div>
    <div class="form-group">
        <label class="col-sm-2 control-label">医院名称</label>
        <label class="col-sm-10 navbar-btn">${hosOrder.hosName}</label>
    </div>
    <div class="form-group">
        <label class="col-sm-2 control-label">医院地址</label>
        <label class="col-sm-10 navbar-btn">${hosOrder.hosAddress}</label>
    </div>
    <div class="form-group">
        <label class="col-sm-2 control-label">医院类别</label>
        <c:if test='${hosOrder.hosType==1}'><label class="col-sm-2 navbar-btn">村</label></c:if>
        <c:if test='${hosOrder.hosType==2}'><label class="col-sm-2 navbar-btn">乡</label></c:if>
        <label class="col-sm-2 control-label">联系人</label>
        <label class="col-sm-2 navbar-btn">${hosOrder.contacts}</label>
        <label class="col-sm-2 control-label">联系电话</label>
        <label class="col-sm-2 navbar-btn">${hosOrder.contactsPhone}</label>
    </div>
    <div class="form-group" id="departmentsDiv">
        <label class="col-sm-2 control-label">科室</label>
        <label class="col-sm-10">
            <c:forEach items="${departmentList}" var="department">
                <label class="col-sm-4">
                    <label class="checkbox-inline">
                        <input type="checkbox" name="depId" value="${department.id}" disabled >
                        <input class="form-control col-sm-2" disabled="disabled" name="showName" value="${department.depName}"  readonly>
                    </label>
                </label>
            </c:forEach>
        </label>
    </div>
    <div class="form-group">
        <label class="col-sm-2 control-label">营业执照</label>
        <div class="col-sm-10">
            <img src="${hosOrder.imageUrl}" class="img-thumbnail" alt="Cinque Terre" width="800" height="700">
            <%--<img src="data:image/png;base64,${hosOrder.image}" class="img-thumbnail"  width="800" height="700"/>--%>
        </div>
    </div>
    <div class="modal-footer" style="text-align: center ">
        <button type="button" class="btn btn-default" onclick="window.history.go(-1)">返回</button>
        <button type="submit" class="btn btn-primary">生成医院信息</button>
    </div>
</form>
</div>

<script type="text/javascript">
    $(document).ready(function() {
        var depIdArr = [];
        var showNameArr = [];

        setDepartmentInit();
        /**
         * 初始化科室的值
         * */
        function setDepartmentInit(){
            <c:forEach items="${departmentList}" var="department">
            <c:forEach items="${hdList}" var="hb">
            <c:if test="${department.id == hb.depId}">
            depIdArr.push('${department.id}');
            showNameArr.push('${hb.showName}');
            </c:if>
            </c:forEach>
            </c:forEach>
            for (var k=0; k<depIdArr.length; k++){
                $("input[name='depId']").each(function(){
                    if($(this).val()==depIdArr[k]){
                        $(this).attr("checked","checked");
                        return false;
                    }
                });
            }
        }

        $("#myForm").submit(function(){
            $.ajax({
                url:'${ctx}/hosOrder/validateHospOrderStatus',
                type:'post',
                data:{id:${hosOrder.id}},
                async : false, //默认为true 异步
                error:function(data){
                    alert('error');
                },
                success:function(data){
                    if(data.success){
                        $.ajax({
                            url:'${URL_ADM_HOS_ORDER_TOADDHOSP}',
                            type:'post',
                            data:{id:${hosOrder.id}},
                            async : false, //默认为true 异步
                            error:function(data){
                                alert('error');
                            },
                            success:function(data){
                                var mesg = window.open("about:blank");
                                mesg.document.write(data);
                                mesg.document.close();
                            }
                        });
                    }else{
                        alert(data.msg);
                    }

                }
            });
            return false;
        });
    });

    function toSearch(){
        window.location.href='${URL_ADM_HOS_ORDER_TOSEARCH}';
    }

</script>
</body>
</html>